<?php

namespace Biz\Requests\Site;

use Illuminate\Validation\Rule;
use Biz\Constants\ModuleConstants;
use Biz\Constants\ApplicationConstants;
use Biz\Constants\Site\SiteMenuConstants;
use Lumen\Validation\Rules\AttributeInRule;
use Lumen\Validation\Validators\RequestValidator;

/**
 * SiteMenuRequest.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class SiteMenuRequest extends RequestValidator
{
    /**
     * Get custom rules for validator errors.
     *
     * @return array
     */
    public function rules(): array
    {
        return [
            'parent_id'                            => 'required|alpha_num|max:128',
            'url'                                  => 'required|string|max:128',
            'module'                               => [
                'required',
                'alpha',
                'max:32',
                Rule::in(ModuleConstants::$Modules),
            ],
            'position'                       => [
                'required',
                'alpha',
                'max:32',
                Rule::in(SiteMenuConstants::$Positions),
            ],
            'target_id'                              => 'required|alpha_num|max:128',
            'translations'                           => 'required',
            'translations.*'                         => [
                'required',
                new AttributeInRule(ApplicationConstants::$Languages),
            ],
            'translations.*.name'                    => 'required|max:255',
            'translations.*.description'             => 'max:255',
        ];
    }
}
